<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
	<head>
		<meta charset="utf-8">
        <meta http-equiv="X-UA-Compatible" content="IE=edge">
        <meta name="viewport" content="width=device-width, initial-scale=1">
        <meta name="description" content="Responsive Admin Dashboard Template">
        <meta name="keywords" content="admin,dashboard">
        <meta name="author" content="skcats">
		<title></title>
        <link rel="stylesheet" th:href="@{/layui/css/layui.css}" media="all" />
        <link th:href="@{/assets/plugins/bootstrap/css/bootstrap.min.css}" rel="stylesheet">
        <link th:href="@{/assets/plugins/font-awesome/css/font-awesome.min.css}" rel="stylesheet">
        <link th:href="@{/assets/css/custom.css}" rel="stylesheet">
        <script th:src="@{/assets/plugins/jquery/jquery-3.1.0.min.js}"></script>
        <script th:src="@{/layui/layui.js}"></script>
	</head>
	<style>
    .utable .layui-laypage .layui-laypage-curr .layui-laypage-em {
            background-color: #1E9FFF;
    }
    .layui-table-page {
            text-align: center;
    }
    .layui-table {
        text-align: center;
        margin-top: -10px;
    }
    .layui-table-view thead th {
        text-align: center;
        font-weight: bold;
    }
    .layui-table-view tbody td {
        text-align: center;
    }
	</style>
<body>

<!--表内功能-->
    <script id="bar" type="text/html">
        {{#  if(d.status === 1){ }}

        <a id="upd" class="layui-btn layui-btn-xs" lay-event="upd">
            <i class="layui-icon">&#xe642;</i>编辑
        </a>

        {{#  } }}

	</script>

<!--数据表格样式及附件-->
<script id="toolbarDemo" type="text/html">
    <div class="layui-btn-container">
        <button id="add" class="layui-btn layui-btn-sm" th:if="${session.user.post_Id != 1}"><i class="layui-icon">&#xe654;</i>添加未打卡说明</button>
        <button id="aduit" class="layui-btn layui-btn-sm" th:if="${session.user.post_Id == 1 || session.user.post_Id == 2}"><i class="layui-icon">&#xe606;</i>我的审批</button>
    </div>

</script>
<!--表格-->
<div class="utable">
    <table class="layui-table" id="demo" lay-filter="demo"></table>
</div>


</body>
<script type="text/javascript" th:inline="none">
    layui.use('table', function () {
        var table = layui.table;

        //方法渲染
        table.render({
            elem: '#demo'
            ,id: 'tab'
            ,height: 520
            ,width: 1250
            ,url: '/check/listdata2' //数据接口
            ,page: true //开启分页
            ,toolbar: '#toolbarDemo'
            ,cols: [[ //表头
                {field: 'checkingid', title: '编号', sort: true}
                ,{field: 'emp_Name', title: '员工姓名'}
                ,{field: 'punchtime', title: '未打卡时间'}
                ,{field: 'cause', title: '原因说明'}
                ,{field: 'auditperson', title: '审核人'}
                ,{field: 'audittime', title: '审核时间'}
                ,{field: 'remark', title: '审核说明'}
                ,{field: 'status', title: '状态', templet: aaa}
                ,{fixed: 'right', title:'操作', toolbar: '#bar'}
            ]]
        });

        //点击添加iframe窗方法
        $("#add").on('click',function(){
            //iframe窗
            layer.open({
                type: 2,
                title: '未打卡说明',
                maxmin: true, //开启最大化最小化a按钮
                area: ['430px', '420px'],
                content: ['/check/toadd']//这是链接你的页面地址 url
            });
        })

        $("#aduit").on('click',function(){

            document.location.href = "/aduitcheck/checkqlist";

        })

        //监听行工具事件
        table.on('tool(demo)', function (obj) {
            var data = obj.data;//获取数据
            if (obj.event == 'upd') {//修改

                layer.open({
                    type: 2,
                    title: '未打卡说明修改',
                    maxmin: true, //开启最大化最小化a按钮
                    area: ['430px', '420px'],
                    content: ['/check/toupd?id='+data.checkingid]//这是链接你的页面地址 url
                });

            }
        })

        //启用禁用
        function aaa(data){
            var status = data.status;
            var btns = "";
            if (status == 1) {
                btns += '<span style="color:#ed2a4a">未审核</span>';
            }
            if (status == 2) {
                return"通过";
            }
            if (status == 3) {
                btns += '<span style="color:#ed2a2a">不通过</span>';
            }
            return btns;
        }
    });
</script>
</html>